var Money = require('../models/money');

var data = require('../../data/2014-12-30').reverse();

var monies = data.map(function(item) {
    return new Money(item);
});

function complete() {
    console.log('ok');
}

function save(i) {
    if (i > monies.length) {
        complete();
    } else {
        monies[i].save(function(err) {
            if (err) {
                throw err;
            }
            console.log('saved %s/%s', i, monies.length);
            console.log(monies[i]);
            console.log();

            i += 1;
            save(i);
        });
    }
}

save(0);
/*Money.collection.insert(data, function(err) {
    if (err) {
        throw err;
    }
    console.log('ok');
});
*/
